import Vue from "vue"
import Router from "vue-router"

// 导入页面组件
import Home from "../components/Home"
import Login from "../components/Login"
import Register from "../components/Register"
import Course from "../components/Course"
import Detail from "../components/Detail"
import Player from "../components/Player"
import Cart from "../components/Cart"
import Order from "../components/Order"
import Success from "../components/Success"
import User from "../components/User"
import UserOrder from "../components/UserOrder"


Vue.use(Router);

export default new Router({
  // 设置路由模式为‘history’，去掉默认的#
  mode: "history",
  routes:[
    // 路由列表
     {
       name:"Home",
       path:"/",
       component:Home,
     },
      {
       name:"Home",
       path:"/home",
       component:Home,
     },
      {
       name:"Login",
       path:"/login",
       component: Login,
     },
      {
       name:"Register",
       path:"/reg",
       component: Register,
     },
      {
       name:"Course",
       path:"/course",
       component: Course,
     },
      {
       name:"Detail",
       path:"/detail",
       component: Detail,
     },
      {
       name:"Player",
       path:"/player",
       component: Player,
     },
      {
       name:"Cart",
       path:"/cart",
       component: Cart,
     },
      {
       name:"Order",
       // 地址栏的命名绑定参数, 在组件中可以通过 this.$router.param.order可以获取数据
       path:"/orders/:order",
       component: Order,
     },
      {
       name:"Success",
       // 地址栏的命名绑定参数, 在组件中可以通过 this.$router.param.order可以获取数据
       path:"/success",
       component: Success,
     },
    {
      name:"User",
      path:"/my",
      component: User,
      // children:[  // 设置子路由,在父级路由对应的组件中如果存在父子公用部分页面,可以使用router-view来实现子路由
      //   {
      //     name:"UserOrder",
      //     path:"/order",
      //     component: UserOrder,
      //   }
      // ]
    },
    {
      name:"UserOrder",
      path:"/my/order",
      component: UserOrder,
    },
  ]
})
